package com.icongyou.enterprise.talent_pool.mapper;

import com.icongyou.enterprise.talent_pool.entity.TalentSearchHistory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@Mapper
public interface TalentSearchHistoryMapper {
    int insert(TalentSearchHistory history);
    int updateSearchCount(@Param("userId") String userId, @Param("demandText") String demandText,
                          @Param("lastSearchTime") LocalDateTime lastSearchTime);
    Optional<TalentSearchHistory> findByUserIdAndDemandText(@Param("userId") String userId,
                                                            @Param("demandText") String demandText);
    List<TalentSearchHistory> findByUserIdOrderByLastSearchTimeDesc(@Param("userId") String userId,
                                                                    @Param("limit") int limit);
    int countByUserId(@Param("userId") String userId);
    int deleteOldestByUserId(@Param("userId") String userId, @Param("count") int count);
    int deleteById(@Param("id") String id);
}